#include "../include/Equation.h"

double f1(double x)
{
    return 1 / x - tan(x);
}

double f2(double x)
{
    return 1 / x - pow(2, x);
}

double f3(double x)
{
    return pow(2, -1 * x) + pow(E_, x) + 2 * cos(x) - 6;
}

double f4(double x)
{
    return (pow(x, 3) + 4 * pow(x, 2) + 3 * x + 5) / (2 * pow(x, 3) - 9 * pow(x, 2) + 18 * x - 2);
}

int main()
{
    Bisection first_solver(f1);
    cout << "(1):" << endl;
    cout << first_solver.solve(0, PI / 2) << endl;
    cout << f1(first_solver.solve(0, PI / 2)) << endl;

    //(2)
    cout << endl;
    cout << "(2):" << endl;
    Bisection second_solver(f2);
    cout << second_solver.solve(0, 1) << endl;
    cout << f2(second_solver.solve(0, 1)) << endl;

    //(3)
    cout << endl;
    cout << "(3):" << endl;
    Bisection third_solver(f3);
    cout << third_solver.solve(1, 3) << endl;
    cout << f3(third_solver.solve(1, 3)) << endl;

    cout << endl;
    cout << "(4):" << endl;
    Bisection forth_solver(f4);
    cout << forth_solver.solve(0, 4) << endl;
    cout << f4(forth_solver.solve(0, 4)) << endl;

    return 0;
}